package com.lsb.blog.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lsb.blog.mapper.ArticleMapper;
import com.lsb.blog.pojo.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @author ：liusibo
 * @description：TODO
 * @date ：2021/8/4 23:24
 */
@Component
public class ThreadService {

    @Autowired
    private ArticleMapper articleMapper;

    //将该方法任务 扔入 taskExecutor线程池 开启线程异步执行 不影响主线程的业务
    @Async("taskExecutor")
    public void updateViewCount(Long articleId){
        articleMapper.updateViewCountByArticleId(articleId);
    }

    //将该方法任务 扔入 taskExecutor线程池 开启线程异步执行 不影响主线程的业务
    @Async("taskExecutor")
    public void updateCommentCount(Long articleId){
        articleMapper.updateCommentCountByArticleId(articleId);
    }
}
